package io.github.junxworks.qt.modules.tushare.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;

import io.github.junxworks.ep.core.orm.BaseMapper;
import io.github.junxworks.qt.config.ds.Sharding;

/**
 * @program :springbootdev
 * @description:
 * @author:Junxworks
 * @create:2019-08-16 19:49
 */
@Sharding
public interface FinanceMapper extends BaseMapper {
	@Delete("delete from d_stock_income_ods where ts_code=#{tsCode} and end_date=#{period}")
	int deleteIncomeOdsByPeriod(@Param("tsCode") String tsCode, @Param("period") String period);

	@Delete("delete from d_stock_cashflow_ods where ts_code=#{tsCode} and end_date=#{period}")
	int deleteCashflowOdsByPeriod(@Param("tsCode") String tsCode, @Param("period") String period);

	@Delete("delete from d_stock_balancesheet_ods where ts_code=#{tsCode} and end_date=#{period}")
	int deleteBalancesheetOdsByPeriod(@Param("tsCode") String tsCode, @Param("period") String period);

	@Delete("delete from d_stock_fina_indicator_ods where ts_code=#{tsCode} and end_date=#{period}")
	int deleteFinaIndicatorOdsByPeriod(@Param("tsCode") String tsCode, @Param("period") String period);

	@Delete("delete from d_stock_fina_mainbz where ts_code=#{tsCode} and end_date=#{period}")
	int deleteFinaMainBzByCodeAndPeriod(@Param("tsCode") String tsCode, @Param("period") String period);

	@Delete("delete from d_stock_fina_mainbz where end_date=#{period}")
	int deleteFinaMainBzByPeriod(@Param("period") String period);

	@Delete("delete from d_stock_forecast where ts_code=#{tsCode} and end_date=#{period}")
	int deleteForecastByPeriod(@Param("tsCode") String tsCode, @Param("period") String period);

	@Delete("delete from d_stock_holdernumber where ts_code=#{tsCode} and end_date>=#{startDate} and end_date<=#{endDate}")
	int deleteStockHolderByTsCodeAndDateRange(@Param("tsCode") String tsCode, @Param("startDate") String startDate, @Param("endDate") String endDate);

	@Delete("delete from d_stock_holdernumber where end_date=#{endDate}")
	int deleteStockHolderByDate(String endDate);

	/*****************************************************洗财报数据************************************************************/

	@Delete("delete from d_stock_income where end_date=#{period}")
	int deleteIncomeByPeriod(@Param("period") String period);

	int cleanIncomeByPeriod(@Param("period") String period);

	@Delete("delete from d_stock_cashflow where end_date=#{period}")
	int deleteCashflowByPeriod(@Param("period") String period);

	int cleanCashflowByPeriod(@Param("period") String period);

	@Delete("delete from d_stock_balancesheet where end_date=#{period}")
	int deleteBalancesheetByPeriod(@Param("period") String period);

	int cleanBalancesheetByPeriod(@Param("period") String period);

	@Delete("delete from d_stock_fina_indicator where end_date=#{period}")
	int deleteFinaIndicatorByPeriod(@Param("period") String period);

	int cleanFinaIndicatorByPeriod(@Param("period") String period);
}
